﻿using System;
using Picnic.Spec.Utils;

namespace Picnic.Spec
{
	/// <summary>
	/// Represents a specification statement.
	/// </summary>
	public class Statement
	{
		private readonly string _text;
		private readonly Action _before;
		private readonly Action _body;

		/// <summary>
		/// Initializes a new instance of the <see cref="Statement"/> class.
		/// </summary>
		public Statement(string text, Action body)
			: this(text, null, body)
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="Statement"/> class.
		/// </summary>
		public Statement(string text, Action before, Action body)
		{
			Ensure.That(() => text).IsNotNullOrEmpty();
			Ensure.That(() => body).IsNotNull();

			_text = text;
			_before = before;
			_body = body;
		}

		/// <summary>
		/// Gets a statement text.
		/// </summary>
		public string Text
		{
			get { return _text; }
		}

		/// <summary>
		/// Gets an action which should be executed before statement body.
		/// </summary>
		public Action Before
		{
			get { return _before; }
		}

		/// <summary>
		/// Gets a statement validation action.
		/// </summary>
		public Action Body
		{
			get { return _body; }
		}
	}
}